import Vue from 'vue'
import Router from 'vue-router'
import Login from '@/components/Login'
import Home from '@/components/Home'
import Main from '@/components/page/Main'
import SearchSurplus from '@/components/module/SearchSurplus'
import TransferAccounts from '@/components/module/TransferAccounts'
import OptionSuccess from '@/components/module/OptionSuccess'
import SearchHistory from '@/components/module/SearchHistory'
import UpdatePassword from '@/components/module/UpdatePassword'

Vue.use(Router)

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

export default new Router({
  routes: [
    {
      path: '/',
      name: 'Login',
      component: Login
    },
    {
      path: '/Home',
      component: Home,
      children: [
        {
          path: '/',
          name: 'Main',
          component: Main
        },
        {
          path: '/SearchSurplus',
          name: 'SearchSurplus',
          component: SearchSurplus
        },
        {
          path: '/TransferAccounts',
          name: 'TransferAccounts',
          component: TransferAccounts
        },
        {
          path: '/OptionSuccess',
          name: 'OptionSuccess',
          component: OptionSuccess
        },
        {
          path: '/SearchHistory',
          name: 'SearchHistory',
          component: SearchHistory
        },
        {
          path: '/UpdatePassword',
          name: 'UpdatePassword',
          component: UpdatePassword
        }
      ]
    }
  ]
})
